from __future__ import print_function

"""@package tagengine.commons
The common classes and functions for the TAG Engine.

@author Shuhao Wu
This module provides some basic functions needed across multiple files in the TAG Engine.
This helps with code recycling."""

import sys

def firstUpper(s):
    """Make the first letter of a string upper case.
    
    @param s The string you wish to made the first letter uppercase."""
    return s[0].upper() + s[1:]

def camelCase(s, first=False):
    """Make a string appear in camelCase from camel_case
    
    @param s The input string.
    @param first A boolean value that determines whether or not to capitalize the first character."""
    if first:
        s = firstUpper(s)
    s = s.split("_")
    for i in range(1, len(s)):
        s[i] = firstUpper(s[i])
    return "".join(s)
    
class Constants:
    """ Defines constants """
    UNKNOWN_TYPE = -1337
    GAME_TYPE = -2
    ROOM_TYPE = -1
    ITEM_TYPE = 0
    PLAYER_TYPE = 1
    CHARACTER_TYPE = 2

class LockedDictionary(dict):
    # This component is from the EventScripts playerlib.
    # Copyright is from their team.
    def __detattr__(self, name):
        self._raiseError()
    
    def __delitem__(self, name):
        self._raiseError()
    
    def __setattr__(self, name, value):
        self._raiseError()
    
    def __setattribute__(self, name, value):
        self._raiseError()
    
    def __setitem__(self, name, value):
        self._raiseError()
    
    def clear(self):
        self._raiseError()
    
    def pop(self, *a, **kw):
        self._raiseError()
    
    def popitem(self):
        self._raiseError()
    
    def setdefault(*a):
        self._raiseError()
    
    def update(self, *a, **kw):
        self._raiseError()
    
    def _raiseError(self):
        raise KeyError, 'LockedDictionary cannot be modified.'
    
class Maps:
    GenderToSubjectivePronoun = LockedDictionary({0:"it", 1:"he", 2:"she"})
    GenderToObjectivePronoun = LockedDictionary({0:"it", 1:"him", 2:"her"})

class VersionError(Exception): pass
class NoSourceError(Exception): pass
class GeneralFatalError(Exception): pass
class TriggerNotFoundError(Exception): pass
class VarnameNotFoundError(Exception): pass